﻿using EBA.Collections;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace EBA.Reporting.Data
{
    class AdoReportDataColumn : IReportDataColumn
    {

        public AdoReportDataColumn(DataTable table, int index)
        {
            this.ColumnIndex = index;
            this.ColumnName = table.Columns[index].ColumnName;
            this.RowCells = new AdoReportDataCellCollection();

            var rows = table.Rows;
            for (int i = 0; i < rows.Count; i++)
            {
                this.RowCells.Add(new AdoReportDataCell(i, index, (string)rows[i][index]));
            }
        }

        public string ColumnName
        {
            get;
            set;
        }

        public int ColumnIndex
        {
            get;
            set;
        }

        AdoReportDataCellCollection RowCells
        {
            get;
            set;
        }

        IReadonlyList<IReportDataCell> IReportDataColumn.RowCells
        {
            get
            {
                return this.RowCells;
            }
        }
    }
}
